
<template>
   <div class="goods-container">
    <!-- 左侧图片 -->
    <div class="thumb">
      <div class="custom-control custom-checkbox">
        <!-- 复选框 -->
        <input type="checkbox" :id="'cb' + id" class="custom-control-input" :checked="list.goods_state" @change="stateChange" />
        <label class="custom-control-label" :for="'cb' + id" >
          <!-- 商品的缩略图 -->
          <!-- <img :src="list.goods_pic"  /> -->
           <img v-lazy="list.goods_pic" alt="" />
        </label>
      </div>
    </div>
    <!-- 右侧信息区域 -->
    <div class="goods-info">
      <!-- 商品标题 -->
      <h6 class="goods-title">{{list.goods_name}}</h6>
      <div class="goods-info-bottom">
        <!-- 商品价格 -->
        <span class="goods-price">&yen;{{list.goods_price}}</span>
        <!-- 商品的数量 -->
        <Counter :num="list.goods_count" :id="id"></Counter>
      </div>
    </div>
  </div>
</template>

<script>
import Counter from "@/components/cart/counter.vue"
export default {
  components:{
    Counter
  },
  props:{
     id: {
      required: true,
      type: [Number,String]
    },
    list:{
      default:"",
      type:[Object,Array]
    }
  },
  methods:{
    stateChange(e){
       const newState = e.target.checked
      //  console.log(newState)
       this.$emit('state-change',{id:this.id,state: newState})
    }
  }

}
</script>
<style lang="less" scoped>
.goods-container {
  + .goods-container {
    border-top: 1px solid #efefef;
  }
  padding: 0.5rem;
  display: flex;
  .thumb {
    display: flex;
    align-items: center;
    img {
      width: 2rem;
      height: 2rem;
      margin: 0 0.5rem;
    }
    .custom-control{
       display: flex;
    align-items: center;
    }
  }

  .goods-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    .goods-title {
      font-weight: bold;
      font-size: 0.36rem;
    }
    .goods-info-bottom {
      display: flex;
      justify-content: space-between;
      .goods-price {
        font-weight: bold;
        color: red;
        font-size: 0.36rem;
      }
    }
  }
}
</style>
